package com.wakaka.service;

import com.wakaka.pojo.Dept;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

// 降级
@Component
public class DeptClientServerFallbackFactory implements FallbackFactory {

    @Override
    public FeignService create(Throwable throwable) {
        return new FeignService() {
            public List<Dept> queryAll() {
                return null;
            }

            public Dept get(long id) {
                return new Dept().setId(0)
                        .setName("执行服务降级操作，服务被关闭")
                        .setDb_source("服务被关闭,执行服务降级操作");
            }

            public int add(String name) {
                return 0;
            }
        };
    }
}
